class PbContext {

    static userContext = {
        userId: null, userName: null, balance: null,
    };

    static headerContext = {
        header: {
            "Cookie": null,
            "User-Agent": null,
            "Referer": "",
            "Accept": "application/json, text/plain, */*",
            "Host": null,
        }
    };

    static windowsObj = {
        pbWin: null,
        pbWinId: null,
        windowName: "平博",
        windowTitle: "平博",
    }


    /**
     * 保存账号信息
     */
    static refreshUserContext(userId, userName, balance) {
        PbContext.userContext.userId = userId;
        PbContext.userContext.userName = userName;
        PbContext.userContext.balance = balance;
    }


    static refreshHeaderContext(header) {
        PbContext.headerContext.header = header;
    }

    static getUserContext() {
        const userContext = PbContext.userContext;
        if (userContext == null || userContext.userId == null) {
            throw new ReferenceError("账号未登录！");
        }
        return userContext;
    }

    static getHeaderContext() {
        const userContext = PbContext.headerContext;
        if (userContext == null || userContext.userId == null) {
            throw new ReferenceError("账号未登录！");
        }
        return userContext;
    }

}

module.exports = {PbContext};